﻿using System;
using GoblinXNA;
using GoblinXNA.SceneGraph;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using GoblinXNA.Graphics;
using GoblinXNA.Graphics.Geometry;
namespace ping
{
    public class DropPoint : GeometryNode
    {
        static GoblinXNA.Graphics.Model dropPointModel = new Cylinder(2, 0.6f, 3, 5);// (0.5f, 20, 20);
        public static Material sourceMaterial = new Material();
        int speed;
        Boolean enabled;
        TransformNode t;
        
        public int Speed
        {
            get { return speed; }
            set
            {
                if (value > -1 && value < 6)
                    speed = value;
            }
        }

        public Boolean Enabled
        {
            get { return enabled; }
            set { enabled = value; }
        }

        public Vector3 Position
        {
            get { return t.Translation; }
            set { t.Translation = value; }
        }

        public TransformNode Trans
        {
            get { return t; }
        }

        public DropPoint()
        {
            Vector3 newPosition = new Vector3(0, 0, 40);
            speed = 1;
            enabled = true;
            this.Model = dropPointModel;
            // Make this source model cast and receive shadows
            this.Model.CastShadows = true;
            this.Model.ReceiveShadows = true;

            t = new TransformNode();
            t.Translation = newPosition;
            t.Rotation = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.ToRadians(-90));

            // Create a material to apply to the source model
            sourceMaterial.Diffuse = Color.Coral.ToVector4();
            sourceMaterial.Specular = Color.White.ToVector4();
            sourceMaterial.SpecularPower = 10;

            this.Material = sourceMaterial;
            t.AddChild(this);
        }

        public DropPoint(Vector3 position)
        {
            speed = 1;
            enabled = true;
            this.Model = dropPointModel;
            // Make this source model cast and receive shadows
            this.Model.CastShadows = true;
            this.Model.ReceiveShadows = true;

            t = new TransformNode();
            t.Translation = position;
            t.Rotation = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.ToRadians(-90));

            // Create a material to apply to the source model
            sourceMaterial.Diffuse = Color.Coral.ToVector4();
            sourceMaterial.Specular = Color.White.ToVector4();
            sourceMaterial.SpecularPower = 10;

            this.Material = sourceMaterial;
            t.AddChild(this);
        }

        public Ball createBall()
        {
            Ball newBall = new Ball(this.Position);
            return newBall;
        }

    }

}